package se.rkrantz.simpleraid.jetty;

import java.util.logging.Level;
import java.util.logging.Logger;

import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.webapp.WebAppContext;

public class JettyStarter {
    
    private Server server;
    
    public JettyStarter(int port, String warRoot) {
        Logger.getLogger("org.springframework").setLevel(Level.ALL);
        
        server = new Server(port);
        WebAppContext context = new WebAppContext();
        context.setDescriptor(warRoot + "/WEB-INF/web.xml");
        context.setResourceBase(warRoot);
        
        server.setHandler(context);
    }
    
    public void start() throws Exception {
        server.start();
    }
    
    public static void main(String[] arg) throws Exception {
        JettyStarter starter = new JettyStarter(8080, "src/main/webapp/");
        starter.start();
    }
}
